package com.xy.biz.uc.domain.query;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.util.CollectionUtils;

import java.util.ArrayList;
import java.util.List;

@NoArgsConstructor
@AllArgsConstructor
@Builder
@Data
public class RoleIdQuery {

    /**
     * 角色Id集合
     */
    private List<Long> roleIdList;

    /**
     * 是否查询资源
     */
    private boolean withResource;

    public RoleIdQuery addRoleId(Long roleId) {
        if(roleIdList == null) {
            roleIdList = new ArrayList<>();
        }
        roleIdList.add(roleId);
        return this;
    }

    public Long firstRoleId() {
        return CollectionUtils.isEmpty(roleIdList) ? null : roleIdList.get(0);
    }

}
